package Algorithm.set;

import java.util.*;

//相对补集
public class Differ_Set {
    int[] a;
    int[] b;
    int len_a;
    int len_b;
    Differ_Set(int[] a,int []b){
        this.a = a;
        this.b = b;
        this.len_a = a.length;
        this.len_b = b.length;
    }

    public Set solution(){
        Set<Integer> set = new HashSet<>();
        for(int i =0;i<len_a;i++){
            set.add(a[i]);
        }
        for(int i=0;i<len_b;i++){
            set.remove(b[i]);
        }
        return set;
    }
    public static void main(String[] args) {
        int[] a = new int[]{0,3,5,6,9,15,7};
        int[] b = new int[]{8,9,14,15,3,0};
        Differ_Set ds = new Differ_Set(a,b);
        Set<Integer> set = ds.solution();
        Iterator it  = set.iterator();
        while(it.hasNext()){
            System.out.print(it.next()+" ");
        }
    }

}
